package com.miaoji.service.impl;

import com.miaoji.domain.dto.Result;
import com.miaoji.domain.po.ClothCategory;
import com.miaoji.mapper.CategoryMapper;
import com.miaoji.service.ClothCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

//todo 实现方法
@Service
public class ClothCategoryServiceImpl implements ClothCategoryService {
    @Autowired
    CategoryMapper categoryMapper;
    @Override
    public ClothCategory categorySelect(int cloth_id) {
        return categoryMapper.selectById(cloth_id);
    }

    @Override
    public boolean categoryInsert(ClothCategory clothCategory) {
        int insert = categoryMapper.insert(clothCategory);
        if (insert==1){
            System.out.println("成功");
            return Result.ok("插入成功").getSuccess();
        }
        else{
            System.out.println("失败");
            return Result.fail("插入失败").getSuccess();
        }

    }

    @Override
    public boolean categoryUpdate(ClothCategory clothCategory) {
        boolean updateSuccess =categoryMapper.updateByClothId(clothCategory)>0;
        return updateSuccess;
    }

    @Override
    public boolean categoryTreUpdate(int clothId, String categoryTre) {
        return categoryMapper.updateCategoryTre(clothId,categoryTre)>0;
    }

}
